ISCModelObject Interface
The following table contains information on the ISCModelObject interface:
|
Signature |
Description |
Valid Arguments |
|---|---|---|
|
BSTR ClassName() |
Returns the class name of the current object |
None |
|
SC_OBJID ObjectId() |
Uniquely identifies the current object |
None |
|
BSTR Name() |
Returns the name or a string identifier of the current object |
None |
|
SC_CLSID ClassId() |
Returns the class identifier of the current object |
None |
|
ISCModelObject * Context() |
Passes back the context (parent) of the object |
None |
Example 8
The following example illustrates how to access model objects using C++. The example uses the Application object created in Example 1 and the OpenSession function from Example 6:
void IterateObjects(ISCApplicationPtr & scAppPtr)
{
ISCSessionPtr scSessionPtr = OpenSession( scAppPtr ); // From Example 6
//Make sure the Session Ptr is Open
if(!scSessionPtr->IsOpen())
{
AfxMessageBox("Session Not Opened");
return;
}
ISCModelObjectCollectionPtr scModelObjColPtr = scSessionPtr >GetModelObjects();
IUnknownPtr _NewEnum = NULL;
IEnumVARIANT* ObjCollection;
_NewEnum = scModelObjColPtr ->Get_NewEnum();
if (_NewEnum != NULL)
{
HRESULT hr = _NewEnum->QueryInterface(IID_IEnumVARIANT, (LPVOID*) &ObjCollection);
if (!FAILED(hr))
{
while (S_OK == ObjCollection->Next(1,&xObject,NULL))
{
ISCModelObjectPtr pxItem = (V_DISPATCH (&xObject));
// ISCModelObject in xObject was AddRefed already. All we need is to
//attach it to a smart pointer
xObject.Clear();
// Process the Item
CString csName = (LPSTR) pxItem->GetName();
CString csID = (LPSTR) pxItem->GetObjectId();
CString csType = (LPSTR) pxItem->GetClassName();
// …
}
if (ObjCollection)
ObjCollection->Release();
}
}
The following example illustrates how to access model objects using Visual Basic .NET. The example uses the Application object created in Example 1 and the OpenSession function from Example 6:
Public Sub IterateObjects(ByRef scApp As SCAPI.Application)
Dim scSession As SCAPI.scSession
Dim scModelObjects As SCAPI.ModelObjects
Dim scObj As SCAPI.ModelObject
scSession = OpenSession( scApp ) ' From Example 6
' Make sure that the session is open
If scSession.IsOpen() Them
scModelObjects = scSession.ModelObjects
For Each scObj In scModelObjects
Console.WriteLine( scObj.Name )
Console.WriteLine( scObj.ObjectId )
Dubug.WriteLine( scObj.ClassName )
Next
End If
End Sub
|
Copyright © 2025 Quest Software, Inc. |